package com.mh.study.springcloud.controller;

import com.mh.study.springcloud.service.ResumeService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * @author MH
 * @since 2022-02-20
 */
@RestController
@RequestMapping("/resume")
public class ResumeController {

    @Value("${server.port}")
    private Integer port;

    @Autowired
    private ResumeService resumeService;

    @GetMapping("/open-state/{userId}")
    public Integer findDefaultResumeState(@PathVariable Long userId) {
        return resumeService.findDefaultResumeByUserId(userId).getIsOpenResume();
    }

    @GetMapping("/get-port")
    public Integer getPort(){
        return this.port;
    }

    @GetMapping("/get-port-2")
    public Integer getPort2(){
        try {
            Thread.sleep(3000L);
        } catch (InterruptedException e) {
            e.printStackTrace();
        }
        return this.port;
    }

}
